<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>自定义菜单</title>
	<link rel="shortcut icon" type="image/ico" href="${basePath}/favicon.ico?v=1"/>
	<link rel="stylesheet" type="text/css" href="${basePath}/css/style-1.css" />
	<link rel="stylesheet" type="text/css" href="${basePath}/css/style_2_common.css" />
	<link rel="stylesheet" type="text/css" href="${basePath}/css/cymain.css" />
	<link rel="stylesheet" type="text/css" href="${basePath}/css/menu.css" />
	<script type="text/javascript" src="${basePath}/js/jquery-1.8.3.min.js"></script>
	<script type="text/javascript" src="${basePath}/js/diymen.js"></script>
	<script type="text/javascript" src="${basePath}/js/yyucadapter.js"></script>
	<script type="text/javascript" src="${basePath}/js/upyun.js"></script>
	<link rel="stylesheet" type="text/css" href="${basePath}/js/layer/skin/layer.css" />
    <script type="text/javascript" src="${basePath}/js/layer/layer.m.js"></script>
    <script type="text/javascript" src="${basePath}/js/layer/extend/layer.ext.js"></script>
    <script type="text/javascript">var yyuc_jspath = "${basePath}";</script>	
</head>
<body id="nv_member" class="pg_CURMODULE">
<#assign current='menu_custom'>
	<div id="wp" class="wp">
		<#include "/include/header.html"/>
		<!--中间内容-->
		<div class="contentmanage">
			<div class="developer">
				<div class="tableContent">
					<#include "/include/left.html"/>
					<#include "/include/wxtop.html"/>
					<div class="content">
						<div class="cLineB">
							<h4>
								<span class=""><h4 style="font-size:16px;">自定义菜单</h1></span>
							</h4>
						</div>
						<a name="main"></a>
						<div style="margin: 10px auto;" class="ftip">
							1.使用本模块生成微信端，必须在微信公众平台
							<strong>申请</strong>自定义菜单使用的
							<strong>AppId和AppSecret</strong>，然后在【授权设置】中设置。<br>2.微信端最多创建
							<span class="red bold">3 个一级菜单</span>，每个一级菜单下最多可以创建
							<span class="red bold">5 个二级菜单</span>，菜单
							<span class="red bold">最多支持两层</span>。（多出部分会生成前3个一级菜单）
						</div>
						<table>
							<tbody>
								<tr>
									<td>
										<div class="bgdpng" style="background-image: url('${basePath}/images/3CustomLt3.png'); width: 344px; height: 623px; position: relative;">
											 <#if (child1_list?exists && child1_list?size>0) >
											    
											      <div class="child-menu zicaidan1" zcdrel="maincd1" style="position: absolute; bottom: 170px; left: 44px;">
												      <#list child1_list as childMenu>
												        <div data-id="${childMenu.id!}" rel="zizicd1" class="zizicd edit-menu" style="width: 83px;">${childMenu.mName!}</div>
											          </#list>
											      </div>
											</#if>
											<#if (child2_list?exists &&child2_list?size>0) >
											      <div class="child-menu zicaidan2" zcdrel="maincd2" style="position: absolute; bottom: 170px; left: 130px;">
												     <#list child2_list as childMenu>
												        <div data-id="${childMenu.id!}" rel="zizicd1" class="zizicd edit-menu" style="width: 83px;">${childMenu.mName!}</div>
											         </#list>
											      </div>
											</#if>
											<#if (child3_list?exists && child3_list?size>0) >
											      <div class="child-menu zicaidan3" zcdrel="maincd3" style="position: absolute; bottom: 170px; left: 216px;">
												      <#list child3_list as childMenu>
												      <div data-id="${childMenu.id!}" rel="zizicd1" class="zizicd edit-menu" style="width: 83px;">${childMenu.mName!}</div>
											          </#list>
											      </div>
											</#if>
											<div style="position: absolute; bottom: 122px; left: 43px;">
												<table cellspacing="0" cellpadding="0" class="caiduannum"
													style="border: none;">
													<tbody>
														<tr>
														   <#assign x=1>
														   <#list rootList as menu>
														      <td><div class="maincd  edit-menu" data-child="${x}" style="height: 45px; width: 86px; line-height: 45px; text-align: center;" data-id="${menu.id!}">${menu.mName!}</div></td>
							 						        <#assign x=x+1>
							 						      </#list>
														</tr>
													</tbody>
												</table>
											</div>
										</div></td>
									<td valign="top"><br>
										<div style="text-align: right; position: relative; width: 100%">
											<a href="index" style="line-height: 30px;" class="btnGreen">新增菜单</a>
										</div><br>
										<form method="get" id="form" action="add">
										<input type="hidden" value="" name="menu_id" id="menu_id" />
										<input type="hidden" value="" name="key_id" id="key_id" />
										<input type="hidden" value="" name="m_name" id="m_name" />
										<input type="hidden" value="" name="menu_type" id="menu_type" value="1"/>
										<input type="hidden" value="" name="key_type" id="key_type" />
										<div id="czselarea">
											<div style="line-height: 16px; padding-bottom: 0px;"
												class="alert alert-info" id="top">
												父级菜单： 
												<select id="pid" name="pid">
													     <option value="0">请选择一级菜单：</option>
													<#list rootList as menu>
							       						 <option value="${menu.id!}" <#if menu.id! == now_menu.pid> selected="selected"</#if>>${menu.mName!}</option>
							 						 </#list>
												</select><span
												style="color: red">二级菜单需要选择父菜单</span>
											</div>
											<div style="line-height: 16px; padding-bottom: 0px;" class="alert alert-info" id="top">
												菜单名称：
												<input type="text" style="margin-top: 6px;" name="title" id="cdmcinpo" value="${now_menu.mName!}">
												<span style="color: red">一级菜单最多4个汉字</span>
											</div>
											<div style="line-height: 16px; padding-bottom: 6px;"
												class="alert alert-info">
												显&#12288;&#12288;示： 
												<input type="radio" value="0" <#if now_menu.isShow! == 0> checked="checked"</#if>  name="is_show"  id="is_show" style="outline: medium none;"/>是&#12288;&#12288;
												<input type="radio" value="1" <#if now_menu.isShow! == 1> checked="checked"</#if>  name="is_show"   id="is_show"  style="outline: medium none;">否 
											</div>
											<div style="line-height: 16px; padding-bottom: 0px;"
												class="alert alert-info">
												排&#12288;&#12288;序：
												<input type="text" title="排序" name="sort" id="sortid" value="${now_menu.mOrder!}">
												<span style="color: red">数字大的排在前面（不填默认为0）</span>
											</div>
											<div class="system l"></div>
											<div class="control-group alert alert-info">
												<label for="answertype" class="control-label">菜单类型:</label>
												<div class="controls">
													<select id="answertype" class="menu_type" name="menuType">
														<option <#if menu.type == 1> selected="selected"</#if> value="1">功能模块菜单</option>
														<option <#if menu.type == 2> selected="selected"</#if> value="2">链接地址菜单</option>
														<option <#if menu.type == 3> selected="selected"</#if> value="3">客服类型菜单</option>
													</select>
												</div>
											</div>
											<!-- 关键字  -->
											<div id="res_1" style="display: block;" class="szcjbt alert alert-info">
												功能模块：<input type="text" id="menu_keyword" name="keyword" value="${now_menu.mKeyword!}" readonly><a href="javascript:void(0);" class="a_choose" onclick="makeTabChose();">从资源库选择</a>
											</div>
											<!-- url  -->
											<div id="res_2" class="szcjbt alert alert-info" style="display: none;">
												要链接到的URL地址：<input type="text" name="url" id="menu_key"  value="${now_menu.mHref!}"><br>
												<span style="color: red">必须开启授权, 禁止使用短网址</span><br>
											</div>
											<p style="text-align: center;">
												<button type="button" style="width: 80px; line-height: 30px; margin-top: 10px;" class="btnGreen" id="form_button">提交</button>
											</p>
										</div>
									</form>
									</td>
								</tr>
							</tbody>
						</table>
						<p style="margin-bottom: 20px; margin-left: 90px;">
							<a title="1.级菜单最多只能开启3个，2级子菜单最多开启5个2.一级菜单最多4个汉字，二级菜单最多7个汉字" class="btnGreen" href="create">生成微信端自定义菜单</a>&nbsp;&nbsp;&nbsp;&nbsp;
						</p>
						<!-- 列表 -->
						<table width="100%" cellspacing="0" cellpadding="0" border="0"
							class="ListProduct">
							<thead>
								<tr>
									<th style="width: 60px;">显示顺序</th>
									<th style="width: 320px;">主菜单名称</th>
									<th style="width: 270px;">菜单类型</th>
									<th>是否显示</th>
									<th style="width: 160px;" class="norightborder">操作</th>
								</tr>
							</thead>
							<tbody>
							    <#list rootList as rootmenu>
							           <tr class="hover">
								         	<td class="td25">${rootmenu.mOrder!'0'}</td>
								         	<td  align="left">${rootmenu.mName!}</td>
									        <td>一级菜单-【<#if rootmenu.type == 1>功能模块菜单<#else>链接地址菜单</#if>】 </td>
									        <td><#if rootmenu.isShow == 0>显示<#else>不显示</#if></td>
									        <td colspan="1">
									         	<a title="修改子菜单" href="#main" data-id="${rootmenu.id!}" class="ajax btnGreen cboxElement edit-menu">修改</a>
									         	<a href="javascript:drop_confirm('您确定要删除吗?', 'delete?id=${rootmenu.id!}');" class=" btnGreen ">删除</a>
									        </td>
								         </tr>
							           <#if (rootmenu.childList?size>0) >
											<#list rootmenu.childList as childMune>
											    <tr class="td29">
									         		<td colspan="1" class="td25">${childMune.mOrder!'0'}</td>
								 	 				<td colspan="1"  align="left"><div class="board"><span>${childMune.mName!}</span></div></td>
													<td colspan="1">二级菜单-【<#if childMune.type == 1>功能模块菜单<#elseif childMune.type == 2>链接地址菜单<#else>客服功能菜单</#if>】</td>
													<td><#if childMune.isShow == 0>显示<#else>不显示</#if></td>
													<td colspan="1">
														<a title="修改子菜单" href="#main" data-id="${childMune.id!}" class="ajax btnGreen cboxElement edit-menu">修改</a>
														<a href="javascript:drop_confirm('您确定要删除吗?', 'delete?id=${childMune.id!}');" class=" btnGreen ">删除</a>
													</td>
										 		</tr>   
											</#list>
										</#if>
							   </#list>
							</tbody>
						</table>
					</div>
					<div class="clr"></div>
				</div>
			</div>
		</div>
		<!--底部-->
	</div>
	<#include "/include/footer.html"/>
</body>
    <div style="display:none;" id="pick_item_com">
    	<div style="background: #fefbe4; border: 1px solid #f3ecb9; color: #993300; overflow:hidden; padding: 10px;margin: 10px auto 5px auto;">
			<a href="javascript:void(0);" style="float:left;padding:5px 20px;background:#4EC573; color:#fff;text-decoration:none;">关键词回复模块</a>
	        <a href="javascript:void(0);" style="float:left;padding:5px 20px;background:#4EC573; color:#fff;margin-left:10px;text-decoration:none;">功能模块</a>
		</div>
    	<div id="tab1">
			<div style="font-size: 14px; padding: 5px 10px 10px 20px;">
				<table class="ListProduct" id="keywords" border="0" cellspacing="0" cellpadding="0"
					width="100%">
					<thead>
						<tr>
							<th>标题</th>
							<th>类型</th>
							<th style="width: 80px;">操作 <span class="tooltips"></span></th>
						</tr>
					</thead>
					<tbody>
					</tbody>
				</table>
			</div>
		</div>
		<div class="hidden" id="tab2">
			<div style="font-size: 14px; padding: 5px 10px 10px 20px;">
				<table class="ListProduct" id="func" border="0" cellspacing="0" cellpadding="0"
					width="100%">
					<thead>
						<tr>
							<th>模块</th>
							<th>链接</th>
							<th style="width: 80px;">操作 <span class="tooltips"></span></th>
						</tr>
					</thead>
					<tbody>
					</tbody>
				</table>
			</div>
		</div>
	</div>
<script type="text/javascript">
var msg="${msg!''}";
if(msg != ""){
	tusi(msg);
}
function go(pageIndex){
	$(".layui-layer-content table#keywords tbody").html("");
	$(".layui-layer-content table#keywords").next().remove();
	makeData(pageIndex, ' .layui-layer-content');
}
function pickItem(id, keyword, type){
	$("#menu_keyword").val(keyword);
	$("#key_id").val(id);
	$("#menu_type").val("1");
	//回复的类型
	$("#key_type").val(type);
	layer.close(window.layerIndex);
}
function makeData(pageIndex, select){
	if(!select){
		select = "#pick_item_com";
	}
	var $tBody = $(select+" table#keywords tbody");
	$.post("${basePath}/admin/sub/ajax", {"currentPage":pageIndex}, function(data){
		for(var i=0;i<data.recordList.length;i++){
			var bean = data.recordList[i];
			var keyword = bean.keyword;
			var id = bean.id;
			var type = bean.type;
			var typeName = "";
			if(type==4){
				typeName="音频回复";
			}else if(type==3){
				typeName="多图文回复";
			}else if(type==2){
				typeName="单图文回复";
			}else if(type==1){
				typeName="文本回复";
			}
			var $tr = $('<tr><td>'+keyword+'</td><td>'+typeName+'</td><td class="norightborder"><a href="javascript:void(0);" onclick="pickItem('+id+', \''+keyword+'\', \''+type+'\');">选中</a></td></tr>');
			$tBody.append($tr);
		}
		//分页
		var currentPage=data.currentPage;
		var total=data.total;
		var pages=data.pages;
		var previouspage=data.previouspage;
		var nextpage=data.nextpage;
		var pageText = '<div class="cLine"><div class="pageNavigator" style="float:right;"><div class="pages">共';
		pageText += total+"条记录  ";
		if(pages>0){
			pageText += currentPage;
		}else{
			pageText += 0;
		}
		pageText += "/" + pages + "页";
		if(currentPage>1){
			pageText += '<a href="javascript:go(1);">首页</a>';
		}
		if(previouspage>1){
			pageText += '<a href="javascript:go('+previouspage+');">上一页</a>';
		}
		if(nextpage < pages){
			pageText += '<a href="javascript:go('+nextpage+');">下一页</a>';
		}
		if(currentPage < pages){
			pageText += '<a href="javascript:go('+pages+');">最后一页</a>'
		}
		var $table = $(select+" table#keywords");
		$table.after(pageText);
	},'json');
}
 function choseFunc(herf, name){
	$("#menu_keyword").val(name);
	$("#menu_key").val(herf);
	$("#menu_type").val("2");
	layer.close(window.layerIndex);
}

$(function(){
	makeData(1);
});
</script>
</html>